package org.example.service.middlegateway.controller;

import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.example.service.middlegateway.common.domain.dto.ResponseDTO;
import org.example.service.middlegateway.domain.dto.SearchParamsDTO;
import org.example.service.middlegateway.service.EsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Api(tags = {"查询"})
public class SearchController {

    @Autowired
    private EsService esService;


    @PostMapping("/search/es")
    @ApiOperation(value = "查询接口")
    public ResponseDTO<JSONObject> es(@RequestBody SearchParamsDTO searchParams) {
        JSONObject searchResult = esService.search(searchParams);
        return ResponseDTO.succData(searchResult);
    }
}
